/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.startup.musicstore.test.repository;

import com.startup.musicstore.app.factory.ContactFactory;
import com.startup.musicstore.app.factory.CustomerFactory;
import com.startup.musicstore.app.factory.DemographicFactory;
import com.startup.musicstore.app.factory.NameFactory;
import com.startup.musicstore.model.Contact;
import com.startup.musicstore.model.Customer;
import com.startup.musicstore.model.Demographic;
import com.startup.musicstore.model.Names;
import com.startup.musicstore.services.crud.CustomerCrudService;
import java.util.Date;
import org.junit.*;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 *
 * @author boniface
 */
public class AlbumCategoryJUnitTest1 {
    private CustomerCrudService customerCrudService;
    private static ApplicationContext ctx;

    public AlbumCategoryJUnitTest1() {
    }

    @BeforeClass
    public static void setUpClass() throws Exception {
        ctx = new ClassPathXmlApplicationContext("classpath:com/startup/musicstore/app/conf/applicationContext-*.xml");
    }

    @AfterClass
    public static void tearDownClass() throws Exception {
    }

    @Before
    public void setUp() {
    }

    @After
    public void tearDown() {
    }

    @Test
    public void createCustomer(){
        customerCrudService=(CustomerCrudService)ctx.getBean("customerCrudService");
        Contact con = ContactFactory.getnames("0218907654", "084508656");
        Names nam = NameFactory.getNames("Estelle", "Zietsman");
        Demographic dem = DemographicFactory.getNames("Female", "White", new Date());
        Customer customer = new CustomerFactory
                .Builder("123")
                .Contact(con)
                .Names(nam)
                .Demographic(dem)
            
                .build();
        customerCrudService.persist(customer);
        
        Assert.assertNotNull(customer.getId());
        
        
    }
   
    
}
